package com.example.demo.component;


import com.example.demo.entity.CurrentUserInfo;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author v-yangheng.ea
 * @date 2019/8/6
 * @since 1.0.0
 */
public class BpaThreadLocalUserAuth {

    //当前线程共享当前用户登录信息
    private static final ThreadLocal<CurrentUserInfo> CONTEXTHOLDER = new ThreadLocal<>();

    public static void clearContext() {
        CONTEXTHOLDER.remove();
    }

    public static CurrentUserInfo getContext() {
        CurrentUserInfo currentUserInfo = CONTEXTHOLDER.get();
        return currentUserInfo;
    }

    public static void setContext(CurrentUserInfo currentUserInfo) {
        CONTEXTHOLDER.set(currentUserInfo);
    }


    private BpaThreadLocalUserAuth() {
        // 无参构造
    }
}